clear

********************************************************************************
*** Load and Setup Data ***

* Load FOMC-Bloomberg panel
use "./data/fomc_panel"

* Multiply FX & Stocks by 100
replace fx_2day = fx_2day*100
replace stk_2day = stk_2day*100


* Standardize Asset Changes
rename fx_2day fx_unscl
rename stk_2day stk_unscl
rename yield3m_2day yield3m_unscl
rename yield2y_2day yield2y_unscl
rename yield5y_2day yield5y_unscl
rename yield10y_2day yield10y_unscl
rename exp2y_2day exp2y_unscl
rename exp10y_2day exp10y_unscl
rename tp2y_2day tp2y_unscl
rename tp10y_2day tp10y_unscl

sort ccode 
by ccode: egen fx_std = sd(fx_unscl)
by ccode: egen stk_std = sd(stk_unscl)
by ccode: egen yield3m_std = sd(yield3m_unscl)
by ccode: egen yield2y_std = sd(yield2y_unscl)
by ccode: egen yield5y_std = sd(yield5y_unscl)
by ccode: egen yield10y_std = sd(yield10y_unscl)
by ccode: egen exp2y_std = sd(exp2y_unscl)
by ccode: egen exp10y_std = sd(exp10y_unscl)
by ccode: egen tp2y_std = sd(tp2y_unscl)
by ccode: egen tp10y_std = sd(tp10y_unscl)

sort ccode date
gen fx_2day = fx_unscl/fx_std
gen stk_2day = stk_unscl/stk_std
gen yield3m_2day = yield3m_unscl/yield3m_std
gen yield2y_2day = yield2y_unscl/yield2y_std
gen yield5y_2day = yield5y_unscl/yield5y_std
gen yield10y_2day = yield10y_unscl/yield10y_std
gen exp2y_2day = exp2y_unscl/exp2y_std
gen exp10y_2day = exp10y_unscl/exp10y_std
gen tp2y_2day = tp2y_unscl/tp2y_std
gen tp10y_2day = tp10y_unscl/tp10y_std

* Pre-Crisis
sort ccode 
by ccode: egen fx_std_pre = sd(fx_unscl) if date < td(01dec2007)
by ccode: egen stk_std_pre = sd(stk_unscl) if date < td(01dec2007)
by ccode: egen yield3m_std_pre = sd(yield3m_unscl) if date < td(01dec2007)
by ccode: egen yield2y_std_pre = sd(yield2y_unscl) if date < td(01dec2007)
by ccode: egen yield5y_std_pre = sd(yield5y_unscl) if date < td(01dec2007)
by ccode: egen yield10y_std_pre = sd(yield10y_unscl) if date < td(01dec2007)
by ccode: egen exp2y_std_pre = sd(exp2y_unscl) if date < td(01dec2007)
by ccode: egen exp10y_std_pre = sd(exp10y_unscl) if date < td(01dec2007)
by ccode: egen tp2y_std_pre = sd(tp2y_unscl) if date < td(01dec2007)
by ccode: egen tp10y_std_pre = sd(tp10y_unscl) if date < td(01dec2007)

sort ccode date
gen fx_2day_pre = fx_unscl/fx_std_pre
gen stk_2day_pre = stk_unscl/stk_std_pre
gen yield3m_2day_pre = yield3m_unscl/yield3m_std_pre
gen yield2y_2day_pre = yield2y_unscl/yield2y_std_pre
gen yield5y_2day_pre = yield5y_unscl/yield5y_std_pre
gen yield10y_2day_pre = yield10y_unscl/yield10y_std_pre
gen exp2y_2day_pre = exp2y_unscl/exp2y_std_pre
gen exp10y_2day_pre = exp10y_unscl/exp10y_std_pre
gen tp2y_2day_pre = tp2y_unscl/tp2y_std_pre
gen tp10y_2day_pre = tp10y_unscl/tp10y_std_pre

*Post-Crisis
sort ccode 
by ccode: egen fx_std_post = sd(fx_unscl) if date >= td(01dec2007)
by ccode: egen stk_std_post = sd(stk_unscl) if date >= td(01dec2007)
by ccode: egen yield3m_std_post = sd(yield3m_unscl) if date >= td(01dec2007)
by ccode: egen yield2y_std_post = sd(yield2y_unscl) if date >= td(01dec2007)
by ccode: egen yield5y_std_post = sd(yield5y_unscl) if date >= td(01dec2007)
by ccode: egen yield10y_std_post = sd(yield10y_unscl) if date >= td(01dec2007)
by ccode: egen exp2y_std_post = sd(exp2y_unscl) if date >= td(01dec2007)
by ccode: egen exp10y_std_post = sd(exp10y_unscl) if date >= td(01dec2007)
by ccode: egen tp2y_std_post = sd(tp2y_unscl) if date >= td(01dec2007)
by ccode: egen tp10y_std_post = sd(tp10y_unscl) if date >= td(01dec2007)

sort ccode date
gen fx_2day_post = fx_unscl/fx_std_post
gen stk_2day_post = stk_unscl/stk_std_post
gen yield3m_2day_post = yield3m_unscl/yield3m_std_post
gen yield2y_2day_post = yield2y_unscl/yield2y_std_post
gen yield5y_2day_post = yield5y_unscl/yield5y_std_post
gen yield10y_2day_post = yield10y_unscl/yield10y_std_post
gen exp2y_2day_post = exp2y_unscl/exp2y_std_post
gen exp10y_2day_post = exp10y_unscl/exp10y_std_post
gen tp2y_2day_post = tp2y_unscl/tp2y_std_post
gen tp10y_2day_post = tp10y_unscl/tp10y_std_post



* Label Variables
label var fx_1day "Exchange Rate"
label var fx_2day "Exchange Rate"
label var stk_1day "Stock Return"
label var stk_2day "Stock Return"
label var yield3m_1day "3 Month Yield"
label var yield3m_2day "3 Month Yield"
label var yield2y_1day "2 Year Yield"
label var yield2y_2day "2 Year Yield"
label var yield5y_1day "5 Year Yield"
label var yield5y_2day "5 Year Yield"
label var yield10y_1day "10 Year Yield"
label var yield10y_2day "10 Year Yield"

label var tp2y_1day "2 Year Term Prm"
label var tp2y_2day "2 Year Term Prm"
label var tp10y_1day "10 Year Term Prm"
label var tp10y_2day "10 Year Term Prm"
label var exp2y_1day "2 Year Exp Comp"
label var exp2y_2day "2 Year Exp Comp"
label var exp10y_1day "10 Year Exp Comp"
label var exp10y_2day "10 Year Exp Comp"

label var fx_2day_pre "Exchange Rate"
label var stk_2day_pre "Stock Return"
label var yield3m_2day_pre "3 Month Yield"
label var yield2y_2day_pre "2 Year Yield"
label var yield5y_2day_pre "5 Year Yield"
label var yield10y_2day_pre "10 Year Yield"
label var tp2y_2day_pre "2 Year Term Prm"
label var tp10y_2day_pre "10 Year Term Prm"
label var exp2y_2day_pre "2 Year Exp Comp"
label var exp10y_2day_pre "10 Year Exp Comp"

label var fx_2day_post "Exchange Rate"
label var stk_2day_post "Stock Return"
label var yield3m_2day_post "3 Month Yield"
label var yield2y_2day_post "2 Year Yield"
label var yield5y_2day_post "5 Year Yield"
label var yield10y_2day_post "10 Year Yield"
label var tp2y_2day_post "2 Year Term Prm"
label var tp10y_2day_post "10 Year Term Prm"
label var exp2y_2day_post "2 Year Exp Comp"
label var exp10y_2day_post "10 Year Exp Comp"


* Drop Venezuela, US, Brazil, Mexico, Taiwan, Greece
keep if ccode < 49 
drop if ccode == 5 | ccode == 28 | ccode == 45 | ccode == 15 


* Drop dates - no FOMC announcement / coordinated action
drop if date == td(22may2013)
drop if date == td(08oct2008)


* Start sample in 1995
keep if date >= td(01jan1995)


********************************************************************************
*** Response of international equity indices to monetary shocks ***

*** Full Sample ***
* Advanced
reghdfe stk_2day mps_2day if advanced == 1, noabsorb cluster(ccode time)
outreg2 using "tables\table10_a.xml", replace se bdec(3) bracket label
reghdfe stk_2day mps_2day mpu_2day if advanced == 1, noabsorb cluster(ccode time)
outreg2 using "tables\table10_a.xml", append se bdec(3) bracket label
reghdfe stk_2day_pre mps_2day_pre if advanced == 1, noabsorb cluster(ccode time)
outreg2 using "tables\table10_a.xml", append se bdec(3) bracket label
reghdfe stk_2day_pre mps_2day_pre mpu_2day_pre if advanced == 1, noabsorb cluster(ccode time)
outreg2 using "tables\table10_a.xml", append se bdec(3) bracket label
reghdfe stk_2day_post mps_2day_post if advanced == 1, noabsorb cluster(ccode time)
outreg2 using "tables\table10_a.xml", append se bdec(3) bracket label
reghdfe stk_2day_post mps_2day_post mpu_2day_post if advanced == 1, noabsorb cluster(ccode time)
outreg2 using "tables\table10_a.xml", append se bdec(3) bracket label

* EME
reghdfe stk_2day mps_2day if advanced == 0, noabsorb cluster(ccode time)
outreg2 using "tables\table10_b.xml", replace se bdec(3) bracket label
reghdfe stk_2day mps_2day mpu_2day if advanced == 0, noabsorb cluster(ccode time)
outreg2 using "tables\table10_b.xml", append se bdec(3) bracket label
reghdfe stk_2day_pre mps_2day_pre if advanced == 0, noabsorb cluster(ccode time)
outreg2 using "tables\table10_b.xml", append se bdec(3) bracket label
reghdfe stk_2day_pre mps_2day_pre mpu_2day_pre if advanced == 0, noabsorb cluster(ccode time)
outreg2 using "tables\table10_b.xml", append se bdec(3) bracket label
reghdfe stk_2day_post mps_2day_post if advanced == 0, noabsorb cluster(ccode time)
outreg2 using "tables\table10_b.xml", append se bdec(3) bracket label
reghdfe stk_2day_post mps_2day_post mpu_2day_post if advanced == 0, noabsorb cluster(ccode time)
outreg2 using "tables\table10_b.xml", append se bdec(3) bracket label

********************************************************************************
